import { IRecordAble } from "../IRecordAble";

export class TTRecorder extends IRecordAble{
    protected _recorder:any;
    protected _videoPath:string;

    init(type: string): IRecordAble {
        if(!this._recorder){
            this._recorder = window['tt'].getGameRecorderManager();
            this._recorder.onStop((res:{videoPath:string})=>{
                this._videoPath = res.videoPath;
            })
        }
        return super.init(type);
    }

    startRecord(duration: number=180, frameRate: number=30): void {
        this._recorder.start({duration, frameRate})
    }

    stopRecord(): void {
        this._recorder.stop();
    }

    pauseRecord(): void {
        this._recorder.pause();
    }

    resumeRecord(): void {
        this._recorder.resume();
    }

    get videoPath():string {
        return this._videoPath;
    }

}
